package linkTest_1 
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	/**
	 * 
	 * @author cain in liontravel 2010
	 */
	public class Model extends EventDispatcher
	{
		/**
		 * 連線server資料變動
		 */
		static public const LINK_SERVER_CH:String = "Model_LINK_SERVER_CH";
		/**
		 * 輸出變動
		 */
		static public const OUTPUT:String = "Model_OUTPUT";
		/**
		 * 連線狀態
		 */
		static public const LINK:String = "Model_LINK";
		/**
		 * 無連線狀態
		 */
		static public const DE_LINK:String = "Model_DE_LINK";
		/**
		 * 送出資料
		 */
		static public const SENT_DATRA:String = "Model_SENT_DATRA";
		private var _server:String;
		private var _port:String = "5050";
		private var _output:String;
		private var _isLink:Boolean;
		private var _sent_str:String;
		public function Model() 
		{
			
		}
		/**
		 * 主機位置
		 */
		public function set server(_s:String):void 
		{
			if (_server!=_s) 
			{
				_server = _s;
				dispatchEvent(new Event(LINK_SERVER_CH));
			}
			
		}
		/**
		 * 主機位置
		 */
		public function get server():String 
		{
			return _server;
		}
		/**
		 * 連線PORT
		 */
		public function set port(_p:String):void 
		{
			if (_port!=_p)
			{
				_port = _p;
				dispatchEvent(new Event(LINK_SERVER_CH));
			}
			
		}
		/**
		 * 連線PORT
		 */
		public function get port():String 
		{
			return _port;
		}
		/**
		 * 輸出
		 */
		public function set output(_str:String):void 
		{
			_output = _str + "\n" + _output;
			dispatchEvent(new Event(OUTPUT));
		}
		/**
		 * 輸出
		 */
		public function get output():String 
		{
			return _output;
		}
		/**
		 * 連線狀態
		 */
		public function set isLink(_is:Boolean):void 
		{
			if (_isLink!=_is) 
			{
				_isLink = _is;
				if (_isLink) 
				{
					dispatchEvent(new Event(LINK));
				}else 
				{
					dispatchEvent(new Event(DE_LINK));
				}
			}
		}
		/**
		 * 連線狀態
		 */
		public function get isLink():Boolean 
		{
			return _isLink;
		}
		/**
		 * 送出資料
		 */
		public function set sent_str(_str:String):void 
		{
			_sent_str = _str;
		}
	}
}